package com.doeis.uwork.module;

import com.doeis.minaserver.NettyServer;
import com.doeis.minaserver.container.BasicModule;
import com.doeis.minaserver.session.ClientConnection;
import com.doeis.uwork.packet.PrivateMsgPacket;
import com.doeis.uwork.servce.PrivateMsgService;


/*****因为组外修改成群聊天，现在这个结构满足不了需求，结构和组内聊天一样了*******/
@Deprecated
public class PrivateMsgPacketRouter extends BasicModule {

	private PrivateMsgService privateMsgService;
	
	public PrivateMsgPacketRouter() {
		super("Private Message Packet Router");
	}
	
	public PrivateMsgPacketRouter(String moduleName) {
		super(moduleName);
	}
	@Override
	public void start() {
		privateMsgService = server.getT(PrivateMsgService.class);
	}

	@Override
	public void initialize(NettyServer server) {
		this.server = server;		
	}

	public void route(ClientConnection clientConn, PrivateMsgPacket packet) {
		switch ( packet.getCmd() ) {
		
		case PrivateMsgPacket.CMD_MSG_ADD:
			privateMsgService.addMsg(clientConn, packet);
			break;
			
		case PrivateMsgPacket.CMD_MSG_LIST:
			privateMsgService.listMsg(clientConn, packet);
			break;
		case PrivateMsgPacket.CMD_MSG_LIST_PMSG:
			privateMsgService.listMsg(clientConn, packet);
			break;
			
		case PrivateMsgPacket.CMD_MSG_LIST_SHARE_USER:
			privateMsgService.listShareUser(clientConn, packet);
			break;
		
		case PrivateMsgPacket.CMD_MSG_LIST_PICTURE:
			privateMsgService.listPicture(clientConn, packet);
			break;
		case PrivateMsgPacket.CMD_MSG_GET_MSG_COUNT:
			privateMsgService.getPrivateGroupMsgCount(clientConn, packet);
			break;
		
		default:
			break;
		}		
	}

}
